define('wangwu/sxyc/AppMap',
    [
        'dojo/_base/declare',
        'dojo/_base/lang',
        'dojo/on',
        'dojo/_base/connect',

        'esri/Evented',
        'esri/map',
        'esri/geometry/Point',
        'esri/SpatialReference',

        'esri/layers/ArcGISDynamicMapServiceLayer',
        'esri/layers/ArcGISTiledMapServiceLayer',
        'esri/layers/FeatureLayer',

        'keepsoft/gis/extlayers/GoogleTiledMapServiceLayer',
        'keepsoft/gis/extlayers/TdtTiledMapServiceLayer',
        'keepsoft/gis/MapManager/LayerManager',
        'keepsoft/app/sxyc/Location',
        'keepsoft/app/sxyc/SelectByClick',
        "wangwu/sxyc/Tip",
        'wangwu/sxyc/Channel',
        "wangwu/sxyc/Handle",
        "wangwu/sxyc/getData",
        'wangwu/sxyc/branchCanal'

    ],
    function(declare, lang, on, connect,
             Evented, Map,Point,SpatialReference,
             ArcGISDynamicMapServiceLayer, ArcGISTiledMapServiceLayer,FeatureLayer,
             GoogleTiledMapServiceLayer,TdtTiledMapServiceLayer,LayerManager,Location,SelectByClick,Tip,
             Channel,Handle,getData,branchCanal){
        var d = declare([Evented], {
            _eventMap:{
                'map-did-load':!0
            },
            constructor:function(divId, mapo, o){
                this.mapDivId = divId;

                this.mapOption = mapo;

                this.map = new Map(this.mapDivId, this.mapOption || {
                            //extent:extent
                    });

                this.option = {

                };
                (o)?lang.mixin(this.option, o):0;
                this.layerManager = new LayerManager(this.map, {});

            },
            //----------------------------------------------public-----------------------------------------------
            init:function(){
                //坐标
                this.map.centerAndZoom(new Point(110.68,35.032, new SpatialReference({wkid:4326})), 0);
                this._init();
                
            },

            //---------------------------------------------private----------------------------------------------
            _init:function(){
                /*添加事件侦听*/
                on(this.map, "load", lang.hitch(this, this._baseLayerLoaded));
                this._addLayers();
            },
            _addLayers:function(){
                var url01 = "http://192.168.1.157:8399/arcgis/rest/services/shanxi/baseMap/MapServer";
                this.tiled01 = new ArcGISTiledMapServiceLayer(url01);
                this.tiled01.name = '影    像';
                this.map.addLayer(this.tiled01);
                console.log(this.tiled01);
                // var url02 = "http://192.168.1.157:8399/arcgis/rest/services/shanxi/bound/MapServer";
                // this.tiled02 = new ArcGISDynamicMapServiceLayer(url02);
                // this.tiled02.name = '边    界';
                // this.map.addLayer(this.tiled02);
            },
            _baseLayerLoaded:function(){
               /* var oListbox = document.getElementById("selectAge");
                var indx = oListbox.selectedIndex;
                console.log(oListbox.options[indx].firstChild.nodeValue); //显示的内容
                console.log(oListbox.options[indx].getAttribute("value"));//对应的value
                var name = oListbox.options[indx].firstChild.nodeValue;
                var url = oListbox.options[indx].getAttribute("value");


                on(oListbox,"change",function(){
                    indx = oListbox.selectedIndex;
                    name = oListbox.options[indx].firstChild.nodeValue;
                    url = oListbox.options[indx].getAttribute("value");
                    var ww = document.getElementById("txtValue");
                    ww.value = url;
                });*/
                ///*添加边界*/
                //this.bound = new Channel(this.map, {
                //    layerName:'边界',
                //    queryUrl:'http://192.168.1.157:8399/arcgis/rest/services/shanxi/baseInfo/MapServer/7',
                //    //queryUrl:url,
                //});
                //this.bound.init();
                ///*添加支渠*/
                //this.branchCanal = new Channel(this.map, {
                //    layerName:'支渠',
                //    queryUrl:'http://192.168.1.157:8399/arcgis/rest/services/shanxi/baseInfo/MapServer/4',
                //});
                //this.branchCanal.init();
                ///*添加干渠*/
                //this.TrunkCanal = new Channel(this.map, {
                //    layerName:'干渠',
                //    queryUrl:'http://192.168.1.157:8399/arcgis/rest/services/shanxi/baseInfo/MapServer/6',
                //});
                //this.TrunkCanal.init();
                ///*添加断面*/
                //this.section = new Channel(this.map, {
                //    layerName:'断面',
                //    queryUrl:'http://192.168.1.157:8399/arcgis/rest/services/shanxi/baseInfo/MapServer/5',
                //});
                //this.section.init();
                ///*添加桩点*/
                //this.zhuangdian = new Channel(this.map, {
                //    layerName:'桩点',
                //    queryUrl:'http://192.168.1.157:8399/arcgis/rest/services/shanxi/baseInfo/MapServer/3',
                //});
                //this.zhuangdian.init();
                ///*添加出水池*/
                //this.outletSump = new Channel(this.map, {
                //    layerName:'出水池',
                //    queryUrl:'http://192.168.1.157:8399/arcgis/rest/services/shanxi/baseInfo/MapServer/2',
                //});
                ///*添加分水闸*/
                //this.distributionStructure = new Channel(this.map, {
                //    layerName:'分水闸',
                //    queryUrl:'http://192.168.1.157:8399/arcgis/rest/services/shanxi/baseInfo/MapServer/1',
                //});
                ///*添加泵站*/
                //this.pumpStation = new Channel(this.map, {
                //    layerName:'泵站',
                //    queryUrl:'http://192.168.1.157:8399/arcgis/rest/services/shanxi/baseInfo/MapServer/0',
                //});
                ////this.pumpStation.init();
                //
                ///*添加定位功能模块*/
                //this.locate = new Location(this.map, {
                //    layerid01:this.TrunkCanal.layer.id,
                //    layerid02:this.branchCanal.layer.id,
                //    layerid03:this.pumpStation.layer.id,
                //    layerid04:this.section.layer.id
                //});
                ///*添加点击功能*/
                //this.select = new SelectByClick(this.map, {
                //    layerid01:this.TrunkCanal.layer.id,
                //    layerid02:this.branchCanal.layer.id,
                //    layerid03:this.pumpStation.layer.id,
                //    layerid04:this.section.layer.id,
                //    layerid05:this.tiled01.id
                //});
                //this.select.init();
                ///*添加标注功能*/
                //this.anno = new Tip(this.map);
                /*添加支渠*/
                this.branchCanal = new Channel(this.map, {
                    layerName:'支渠',
                    queryUrl:'http://192.168.1.157:8399/arcgis/rest/services/shanxi/baseInfo_featureLayer/MapServer/6',
                    visibility : false
                });
                this.branchCanal.init();
                /*添加干渠*/
                this.TrunkCanal = new Channel(this.map, {
                    layerName:'干渠',
                    queryUrl:'http://192.168.1.157:8399/arcgis/rest/services/shanxi/baseInfo_featureLayer/MapServer/5'
                });
                this.TrunkCanal.init();
                /*添加泵站*/
                this.pumpStation = new Channel(this.map, {
                    layerName:'泵站',
                    queryUrl:'http://192.168.1.157:8399/arcgis/rest/services/shanxi/baseInfo_featureLayer/MapServer/0'
                });
                this.pumpStation.init();

                this.get=new getData(this.map,{layerid:this.branchCanal.layer.id});
                this.zhiqu=new branchCanal(this.map);
                this.handle=new Handle(this.map);
                this.onMapDidLoad();
            },
            //--------------------------------------------pre event--------------------------------------------------

            //---------------------------------------------event----------------------------------------------------
            onMapDidLoad:function(){
                //console.log('onMapDidLoad...');
            }
        });

        return d;
    });